close all;

% v1_1 = v1(3:end);
% v1_2 = v1(1:end-2);
% a1 = v1_1-v1_2;
% v1f = v1(2:end-1);
% c1f = c1(2:end-1);
% 
% v2_1 = v2(3:end);
% v2_2 = v2(1:end-2);
% a2 = v2_1-v2_2;
% v2f = v2(2:end-1);
% c2f = c2(2:end-1);
% 
% v3_1 = v3(3:end);
% v3_2 = v3(1:end-2);
% a3 = v3_1-v3_2;
% v3f = v3(2:end-1);
% c3f = c3(2:end-1);
% 
% a = [a1; a2; a3];
% vf = [v1f; v2f; v3f];
% cf = [c1f; c2f; c3f];
% 
% f = fittype(@(a,b,c,d,f,x,y) a+b*exp(-c*y)+d*y+f*x,'independent',{'x','y'},'dependent','z')
% cfun = fit([a,vf],cf,f)
% plot(cfun, [a,vf], cf)

% cfun_01 = fit(a1,c1f,'poly1')
% plot(cfun_01, a1,c1f)

f = fittype(@(a,x) a*x, 'independent', 'x', 'dependent', 'z');

cfun1 = fit(v_s(2:175)-v_s(1:174),c_model(2:175)-c_s(2:175),f)
figure
plot(cfun1,v_s(2:175)-v_s(1:174),c_model(2:175)-c_s(2:175))
figure
plot(cfun1,v_s(52001:52101)-v_s(52000:52100),c_model(52001:52101)-c_s(52001:52101))

% cfun1 = fit(v_s(2:175)-v_s(1:174),c_s(2:175),'poly1')
% figure
% plot(cfun1,v_s(2:175)-v_s(1:174),c_s(2:175))

